import { PluginOption } from 'vite'
import Components from 'unplugin-vue-components/vite'
import { NaiveUiResolver } from 'unplugin-vue-components/resolvers'
import { XTailVue3ComponentResolver } from '@xtail/unplugin-vue3'
import { XTailVue3NComponentResolver } from '@xtail/unplugin-vue3-n'

/**
 * 创建自动引入组件 Vite 插件
 *
 * @returns {PluginOption} 自动引入组件 Vite 插件
 */
export const createComponents = (): PluginOption => {
  return Components({
    dts: 'types/components.d.ts',
    dirs: ['src/components'],
    resolvers: [NaiveUiResolver(), XTailVue3ComponentResolver(), XTailVue3NComponentResolver()],
  })
}
